package temp.helloworld.quartz;

import java.util.Date;

import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SimpleTrigger;
import org.quartz.impl.StdSchedulerFactory;

import temp.helloworld.log.LoggerHelper;

public class QuartzTest {
	public static void main(String[] args) {
		QuartzTest q = new QuartzTest();
		try {
			q.startScheduler();
		} catch (SchedulerException e) {
			LoggerHelper.logger.error("",e);
		}
	}

	protected void startScheduler() throws SchedulerException {
		Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
		// JobDetail jobDetail = new JobDetail("testJob",
		// Scheduler.DEFAULT_GROUP,
		// MyJob.class);
		// 结束时间
		// long end = System.currentTimeMillis() + 9000L;
		// 执行10次，每3秒执行一次，到9秒后结束
		// SimpleTrigger trigger = new SimpleTrigger("test", null, new Date(),
		// new Date(end), 10, 3000L);
		// 执行无限次，每3秒执行一次
		// SimpleTrigger trigger = new SimpleTrigger("test", null, new Date(),
		// null, SimpleTrigger.REPEAT_INDEFINITELY, 3000L);
		// scheduler.scheduleJob(jobDetail, trigger);

		scheduler.start();
	}
}